﻿#ifndef BINGMAPPROVIDER_H
#define BINGMAPPROVIDER_H

#include "MapProvider.h"

static const QString RoadMapUrl      = QStringLiteral("http://ecn.t%1.tiles.virtualearth.net/tiles/r%2.png?g=%3&mkt=%4");
static const QString SatelliteMapUrl = QStringLiteral("http://ecn.t%1.tiles.virtualearth.net/tiles/a%2.jpeg?g=%3&mkt=%4");
static const QString HybridMapUrl    = QStringLiteral("http://ecn.t%1.tiles.virtualearth.net/tiles/h%2.jpeg?g=%3&mkt=%4");

static const quint32 AVERAGE_BING_STREET_MAP = 1297;
static const quint32 AVERAGE_BING_SAT_MAP    = 19597;

class BingMapProvider : public MapProvider
{
    Q_OBJECT
public:
    BingMapProvider(const QString &imageFormat, const quint32 averageSize,
                    const QGeoMapType::MapStyle mapType, QObject* parent = nullptr);

    ~BingMapProvider() = default;

    bool isBingProvider() const override { return true; }

protected:
    const QString _versionBingMaps = QStringLiteral("563");
};

// -----------------------------------------------------------
// Bing Road Map, 使用 GCJ-02, 故不再使用！！

class BingRoadMapProvider : public BingMapProvider {
    Q_OBJECT

public:
    BingRoadMapProvider(QObject* parent = nullptr)
        : BingMapProvider(QStringLiteral("png"), AVERAGE_BING_STREET_MAP, QGeoMapType::StreetMap, parent) {}

    QString _getURL(const int x, const int y, const int zoom, QNetworkAccessManager* networkManager) override;
};

// -----------------------------------------------------------
// Bing Satellite Map

class BingSatelliteMapProvider : public BingMapProvider {
    Q_OBJECT

public:
    BingSatelliteMapProvider(QObject* parent = nullptr)
        : BingMapProvider(QStringLiteral("jpg"), AVERAGE_BING_SAT_MAP, QGeoMapType::SatelliteMapDay, parent) {}

    QString _getURL(const int x, const int y, const int zoom, QNetworkAccessManager* networkManager) override;
};

// -----------------------------------------------------------
// Bing Hybrid Map, 道路使用 GCJ-02, 故不再使用！！

class BingHybridMapProvider : public BingMapProvider {
    Q_OBJECT
public:
    BingHybridMapProvider(QObject* parent = nullptr)
        : BingMapProvider(QStringLiteral("jpg"),AVERAGE_BING_SAT_MAP, QGeoMapType::HybridMap, parent) {}

    QString _getURL(const int x, const int y, const int zoom, QNetworkAccessManager* networkManager) override;
};


#endif // BINGMAPPROVIDER_H
